package Servlets;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class AllerServlet
 */
public class AllerServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AllerServlet() {
        super();
        
    }
    @Override
    public void init(ServletConfig config) throws ServletException {
    	System.out.println("Init");
    	super.init(config);
    }
	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("Service");
		//response.getWriter().print("testset");
		ObjectInputStream ois = new ObjectInputStream(request.getInputStream());		
		PrintWriter os = response.getWriter();
	try {
		
			Object object = ois.readObject();
			System.out.println("test");
			System.out.println(object.toString());
			os.print("testsetsetse");
		} catch (ClassNotFoundException e) {
			
			e.printStackTrace();
		}
	}

}
